package com.example.pet.service;

import com.example.pet.dao.UserDao;
import com.hj.pet.api.UserService;
import com.hj.pet.model.User;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImp implements UserService {
    @Autowired
    UserDao userDao;
    @Override
    public User doLogin(String userAccount, String userPwd) {
        // 加密
        userPwd = DigestUtils.md5Hex(userPwd);
        System.out.println(userAccount);
        System.out.println(userPwd);
        return userDao.doLogin(userAccount,userPwd);
    }

    @Override
    public boolean register(String userAccount, String userPwd) {
        userPwd = DigestUtils.md5Hex(userPwd);
        int x = userDao.register(userAccount,userPwd);
        return x > 0;
    }
}
